package jmine.tec.web.servlet.rest.subscription;


import java.util.Map;

import jmine.tec.subscription.ping.PingPublisher;
import jmine.tec.web.servlet.rest.RestImplementor;
import jmine.tec.web.servlet.rest.exception.HttpErrorException;
import bancosys.tec.persist.dao.BeanNotFoundException;

/**
 * Servico para fazer 'pings'.
 * <p>
 *Só deve ser usado em testes
 * 
 * @author takeshi
 */
public class RestPingService extends RestImplementor {

    
    private final PingPublisher pingPublisher;

    /**
     * C'tor
     * 
     * @param pingPublisher {@link PingPublisher}
     */
    public RestPingService(PingPublisher pingPublisher) {
        super();
        this.pingPublisher = pingPublisher;
    }

    /**
     * {@inheritDoc}
     */
    @Override
    protected Object get(String identification, Map<String, String[]> map) throws BeanNotFoundException, HttpErrorException {
        return "ok";
    }

    /**
     * {@inheritDoc}
     */
    @Override
    protected Object post(String identification, Map<String, String[]> params) throws BeanNotFoundException, HttpErrorException {
        this.pingPublisher.pingNew();
        return "ok";
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public String getPreffix() {
        return "ping";
    }

}
